export {};

// 创建一个对象：学生对象，该对象中具有以下属性和方法：
//	1 属性：姓名、性别、成绩、身高、爱好（数组）
// 	2 方法：学习（返回值类型为 void）、敲代码(返回值类型为 string)

// 学生类型别名
type Student = {
  name: string;
  gender: number;
  score: number;
  likes: string[];
  study(): void;
  code: (code: string) => string;
};
// 学生类型实例
let student: Student = {
  name: 'Jack',
  gender: 0, // 0:男，1:女
  score: 90,
  likes: ['吃饭', '敲代码'],
  study() {
    console.log('good good study, day day up');
  },
  code: (code): string => {
    return code;
  },
};

// 使用接口来定义对象类型，约束对象
interface IStudent {
  name: string;
  gender: number;
  score: number;
  likes: string[];
  study(): void;
  code: (code: string) => string;
}

// 学生类型实例
let student2: IStudent = {
  name: 'Jack',
  gender: 0, // 0:男，1:女
  score: 90,
  likes: ['吃饭', '敲代码'],
  study() {
    console.log('good good study, day day up');
  },
  code: (code): string => {
    return code;
  },
};

console.log(student.name);
console.log(student.study(), student.code('html css js'));
